package com.nbgroup.controller;

import com.nbgroup.annotation.HttpMethod;
import com.nbgroup.pojo.Activity;
import com.nbgroup.pojo.common.PageBean;
import com.nbgroup.pojo.common.PageResult;
import com.nbgroup.pojo.common.Result;
import com.nbgroup.pojo.dto.PageActivityDTO;
import com.nbgroup.service.ActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequiredArgsConstructor
@Api(tags = "活动管理")
public class ActivityController {
private final ActivityService activityService;

@HttpMethod("GET")
@GetMapping("/clues/activity/list")
@ApiOperation("活动分页查询")
    public PageBean activityPageQuery(PageActivityDTO pageActivityDTO){
    PageBean pageBean =activityService.activityPageQuery(pageActivityDTO);
    return pageBean;
}
@PostMapping("/clues/activity")
    @ApiOperation("添加活动")
    public Result addActivity(@RequestBody Activity activity){
    activityService.addActivity(activity);
    return Result.success();
}
@PutMapping("/clues/activity")
    @ApiOperation("修改活动")
    public Result updateActivity(@RequestBody Activity activity){
    activityService.updateActivity(activity);
    return Result.success();
}
@GetMapping("/clues/activity/{id}")
    @ApiOperation("活动查询回显")
    public Result queryById(@PathVariable Long id){
    Activity activity=activityService.queryById(id);
    return Result.success(activity);
}
@DeleteMapping("/clues/activity/{id}")
    @ApiOperation("删除活动")
    public Result deleteActivity(@PathVariable Long id){
    activityService.deleteActivity(id);
    return Result.success();
}
}
